%------------------------------------------------------------------
%------------------------------------------------------------------
%   Author: Md. Sazzad Hussain (sazzad.hussain@sydney.edu.au)
%   Learning and Affect Technologies Engineering (LATTE)
%   University of Sydney, 2012
%------------------------------------------------------------------
%------------------------------------------------------------------

%used for deleting given columns in .csv files

clc;
clear all;

% %------------------------------------------------------------------------
lib='/Volumes/My_HD/Drive1/USYD_Research/sazzadPhD_SVN/myLib/csv/converters';
indir='/Volumes/My_HD/Drive1/USYD_Research/Research Data/IAPS Journal/Emotion/1_Feat_Multimodal/temp_mov';
outdir='/Volumes/My_HD/Drive1/USYD_Research/Research Data/IAPS Journal/Emotion/1_Feat_Multimodal/temp_mov2';
nClass=6;%num of classes
colS=57;%start col in csv #57
colE=115;%end col in csv #115
% %------------------------------------------------------------------------

addpath(lib);%framework path
filesDir=dir(indir);%dir info for files path
mkdir(outdir);


for m=1:length(filesDir)
    [path,name,ext,ver] = fileparts(filesDir(m).name);
    if strcmp(ext,'.csv')%.mat files
        disp(name);
        loadFiles=[indir '/' name ext];
        C=textread(loadFiles,'%s','delimiter','\n','bufsize', 100000095);

        
        dataSet={};
        featCSV={};
        labelSet={};
        dataCSV={};
        
        for x=1:length(C)
            dataSet(x,:)=regexp(C{x},',','split');
        end
        [lenR lenC]=size(dataSet);
        
        featCSV=dataSet(:,colS:colE);%features
        labelSet=dataSet(:,((lenC-nClass)+1):end);%labels        
        dataCSV=[featCSV,labelSet];        
        
        CELL2CSV([outdir, '/' ,name,'.csv'],dataCSV,',');        
    end
end

disp('Done');

rmpath(lib);
